package com.sloera.spring.beans.factory;

import java.util.HashMap;
import java.util.Map;

/**
 * 静态工厂方法：直接调用某一个类的静态方法就可以返回 bean 的实例
 *
 * @author sloera
 * @create 2020/4/6
 */
public class StaticCarFactory {
    private static Map<String, Car> cars = new HashMap<>();

    static {
        cars.put("audi", new Car("audi", 30000));
        cars.put("ford", new Car("ford", 40000));
    }

    public static Car getCar(String name) {
        return cars.get(name);
    }
}
